#include<iostream>
using namespace std;
class Solution {
public:
    int firstUniqChar(string s) {
        int countArr[26] = { 0 };

        for (int i = 0; i < s.size(); i++)
        {
            int num = s[i] - 'a';
            countArr[num]++;
        }
        for (int i = 0; i < s.size(); i++)
        {
            if (countArr[s[i] - 'a'] == 1)
                return i;
        }
        return -1;
    }
};